
<SCRIPT LANGUAGE="JavaScript">
<!--
function f_setGrid() {
	f_setAccountFlag();
	f_gridDblFunc(null);
}

function f_setAccountFlag() {
	//alert(document.all("extend_param").value);
	var yearObj = document.all("txtYear");
	var yearMonth = document.all("extend_param").value;

	var curdate = new Date();
	//alert(curdate.getYear());
	yearObj.value = curdate.getYear();

	var monthObj = document.all("selMonth");
	//alert(curdate.getMonth());
	var curMonth = curdate.getMonth() + 1;
	if (curMonth.length == 1) curMonth = "0" + curMonth;
	monthObj.value = "";//curMonth;

	if (yearMonth != "") {
		yearObj.value = yearMonth.split("-")[0];
		monthObj.value = yearMonth.split("-")[1];
	}
}

function f_month_where() {
	
	 var where_sql = "account_flag = ?";

	var orgwhere_sql = document.all("orgwhere_sql").value;
	var orgwhere_value = document.all("orgwhere_value").value;
	var orgwhere_type = document.all("orgwhere_type").value;

	if (orgwhere_sql == "") {
		orgwhere_sql = document.all("where_sql").value;
		orgwhere_value = document.all("where_value").value;
		orgwhere_type = document.all("where_type").value;

		document.all("orgwhere_sql").value = orgwhere_sql;
		document.all("orgwhere_value").value = orgwhere_value;
		document.all("orgwhere_type").value = orgwhere_type;
	}

	var yearObj = document.all("txtYear");
	var monthObj = document.all("selMonth");

	var where_value = yearObj.value + "-" + monthObj.value;
	document.all("extend_param").value = where_value;
	var where_type = "string";

	if (orgwhere_sql != "") {
		where_sql = where_sql + " and (" + orgwhere_sql + ")";
		where_value += ";" + orgwhere_value;
		where_type += ";" + orgwhere_type;
	}

	if (monthObj.value == "") {
		where_sql = orgwhere_sql;
		where_value = orgwhere_value;
		where_type = orgwhere_type;
	}

	document.all("where_sql").value = where_sql;
	document.all("where_value").value = where_value;
	document.all("where_type").value = where_type;

	f_reloadPage();
}





/**
*	
*/
function f_gridDblFunc(keyID) {
	var curKeyID = trselObj.f_get_select_key();
	curKeyID = curKeyID[0];
	if (curKeyID == "") return ;

	var provider_id = trselObj.f_getTDValueByKeyName(curKeyID ,"view_group_urgent.provider_id");
	var cost_unit_id  = trselObj.f_getTDValueByKeyName(curKeyID ,"view_group_urgent.cost_unit_id");
        var item_code = trselObj.f_getTDValueByKeyName(curKeyID ,"view_group_urgent.item_code");

	var is_tax = trselObj.f_getTDValueByKeyName(curKeyID ,"view_group_urgent.is_tax");
	if(is_tax=='<eam:message key = "ddlb.yesno.1" />') is_tax = "1" ;
	else is_tax = "0" ;

        if(item_code ==null || item_code ==""){
	    
		var where_sql = "item_code is null and provider_id = ?  and cost_unit_id = ? and is_tax = ? ";
		var where_type = "string;string;string"
		var where_value = provider_id+";"+cost_unit_id+";"+is_tax;

        }else{
	    
	    	var where_sql = "provider_id = ?  and cost_unit_id = ? and item_code = ?  and is_tax = ? ";
		var where_type = "string;string;string;string";
		var where_value =  provider_id+";"+cost_unit_id+";"+item_code+";"+is_tax;

       }
        var whereMonth = document.all("selMonth").value;
	
	var whereYear = document.all("txtYear").value;
	if (whereMonth != "") {
		where_sql += " and in_urgent.account_flag = ?";
		where_type += ";string";
		where_value += ";" + whereYear + "-" + whereMonth;
	}

	var contextPath = "<%=CONTEXTPATH%>";
	var funcid = "groupaudit_urgent";

	var href = contextPath + "/wzmis/finance/frame_groupaudit_urgent.jsp?funcid=" + funcid + "&pageType=subgrid";
	href += "&where_sql=" + where_sql;
	href += "&where_value=" + where_value;
	href += "&where_type=" + where_type;
	href += "&orgwhere_sql=" + where_sql;
	href += "&orgwhere_type=" + where_type;
	href += "&orgwhere_value=" + where_value;
   
	parent.frames("frmformdata").document.location = href
}



//-->
</SCRIPT>
<table class="gridTbl">
<tr class="gridData">
	<td class="gridData" >
	<eam:message key="column.groupaudit_urgent.in_urgent.account_flag" />: 
	<input type="text" name="txtYear" id="txtYear" size="5" value=""> -
	<select name="selMonth" id="selMonth" onchange="f_month_where(this);">
	<option value=""></option>
	<option value="01">01</option>
	<option value="02">02</option>
	<option value="03">03</option>
	<option value="04">04</option>
	<option value="05">05</option>
	<option value="06">06</option>
	<option value="07">07</option>
	<option value="08">08</option>
	<option value="09">09</option>
	<option value="10">10</option>
	<option value="11">11</option>
	<option value="12">12</option>
	</select>
	</td>
</tr>
</table>
